<template>
    <div>
        <ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media" v-for="item in data" :key="item.id">
					<router-link :to="'/index/news/newsinfo/'+item.id">
						<img class="mui-media-object mui-pull-left" :src="item.img_url">
						<div class="mui-media-body">
							{{item.title}}
							<p class="mui-ellipsis">
                                <span>发表时间：{{item.add_time | dateFormat}}</span>
                                <span>点击:{{item.click}}</span>
                            </p>
						</div>
					</router-link>
				</li>
			</ul>
    </div>
</template>

<script>
import { toast } from 'mint-ui';
export default {
    data() {
        return {
            data: []
        }
    },
    methods: {
        getData() {
            this.$http.get('api/getnewslist').then( res=> {
                if(res.body.status == 0) {
                    this.data = res.body.message;
                }
                else {
                    toast('获取新闻列表失败');
                }
            });
        },
    },
    created() {
        this.getData();
    },
    
}
</script>

<style lang="less">
    .mui-ellipsis {
        display: flex;
        font-size: 12px;
        span:first-child {
            flex: 8;
        }
        span:last-child {
            flex: 2;
        }
    }
    .mui-media-body {
        font-size: 12px;
        p {
            color: skyblue;
            font-size: 10px;
        }
    }
</style>